package com.project.dao.impl;

import com.project.bean.StudentBean;
import com.project.dao.IStuDao;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class StuDaoImpl extends BaseDao implements IStuDao{
    List<StudentBean> listStu=new ArrayList<>();
    @Override
    public List<StudentBean> findByClassId() {
        try {
            this.setConnection();

            this.ps=this.con.prepareStatement("select * from t_class c,t_student s where c.pk_classId=s.fk_classId");
            this.rs=ps.executeQuery();
            listStu=(this.getObject(this.ps.executeQuery()));
            return listStu;
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }finally {
            this.closeConnection();
        }
    }

    public static void main(String[] args) {
        IStuDao stu=new StuDaoImpl();
        System.out.println(stu.findByClassId());
    }
}
